#include "buzzer.h"

#define Buzzer_Pin                  GPIO_Pin_4
#define Buzzer_Port                 GPIOC
#define Buzzer_En(x)                Buzzer_Port->ODR = (Buzzer_Port->ODR & ~Buzzer_Pin)  | (x ? Buzzer_Pin : 0)


//蜂鸣器初始化
void Buzzer_Init(void)
{

    GPIO_InitTypeDef  GPIO_InitStructure;

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);

    GPIO_InitStructure.GPIO_Pin = Buzzer_Pin;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(Buzzer_Port, &GPIO_InitStructure);

    GPIO_ResetBits(Buzzer_Port, Buzzer_Pin);


}
void beep(void)
{
    Buzzer_En(1);
    delay_ms(3);
    Buzzer_En(0);
    delay_ms(3);
}

